package server.content.skills.filling;

import server.event.Event;
import server.event.EventContainer;
import server.event.EventManager;
import server.game.players.Client;

public class Filling {

	private final Client c;

	public Filling(final Client c) {
		this.c = c;
	}

	public void attempt(int objectId) {
		if (objectId > -1) {
			fill();
		}
	}
int curr = -1;
	
	public void fill() {
		final int vialAmnt = c.getItems().getItemCount(229);
		if (vialAmnt > 0) {
			curr = vialAmnt;
		}
		
		c.startAnimation(881);
		c.getPA().requestUpdates();
		EventManager.getSingleton().addEvent(new Event() {

			@Override
			public void execute(EventContainer container) {
				if (curr > 0) {
				c.getItems().addItem(227, 1);
				c.getItems().deleteItem(229, 1);
				curr--;
				} else if (curr == 0) {
					curr = -1;
				container.stop();
				}
			}
		}, 3);
	}

}
